1. What are the strict Interface Requirements?

 

You need to implement the 8 functions defined in the file “utcp.h”.  These functions are basic functions required for any application running on a connection-oriented network protocol.  For functions such as utcpInit and utcpQuit, please provide a dummy implementation if you don’t have any use for them. 

 

In addition you need to define the macro MAX_DATA_LEN in the “utcp.h” file. You are however free to redefine the utcp header and packet structure as you wish and in any other file. But please remember that the value of the maximum data length would depend on the length of the header.

 

Also, in case you need to define any macros for errors (such as done in the dummy implementation) please put it in the “utcp.h” file.

 

  1. What are the linux machines in the csuglab?

 

The following machines in the csuglab run linux: splash, stella, namu, nova, keiko.csuglab.cornell.edu.

 

  1. How to un-tar the associated files?

 

Use the command “tar –xvf helpfiles.tar” in the directory you want to copy the files.

 

  1. How to implement asynchronous IO?

 

In order to receive data and acknowledgement asynchronously, you would need to write a handler for SIGIO signal. This signal is raised whenever an IO event (including a message arrival) occurs.  You can then receive acks and data packets in the SIGIO handler. However, when you call recvfrom or select inside the SIGIO handler, please make sure that it does not block.  The flags argument can be set as in order to prevent there functions from blocking.

 

  1. How to avoid race conditions?

 

There would be at least three components of the code (the main thread, SIGIO handler, timeout handler) that could simultaneously access the data structures.  In order make sure this does not cause race conditions you would need to do certain operations atomically.  This can be achieved by temporarily blocking the SIGIO and SIGALRM signals.  The following is a typical usage to block and release these signals.

 

int mask;

mask = sigblock(signal(SIGIO)|signal(SIGALRM));

critical section;

sigsetmask(mask);

 

Signals should be carefully blocked and released. For example, signals should not be blocked during a blocking system call.  It’s a good idea to block signals to make sure that the send operation is atomic.